package dao;

import org.hibernate.Criteria;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Restrictions;

import to.Aluno;
import util.HibernateUtil;

public class AlunoDAO {

	public Aluno buscaAlunoPorCPF(String cpf) {

		Aluno a = new Aluno();
		Session session = null;

		try {
			
			session = HibernateUtil.getSessionFactory().openSession();
			Criteria criteria = session.createCriteria(Aluno.class, "al");
			criteria.add(Restrictions.eq("al.cpf", cpf));
			a = (Aluno) criteria.uniqueResult();

		} catch (Exception e) {
			e.printStackTrace();
		}
		return a;

	}

}
